<?php
namespace Admin\Controller;

use Think\Controller;

class SystemController extends CommonController{
    private $user;

    function __construct()
    {
        parent :: __construct();
        $this->user = M('User');
    }

    public function change_password(){
        $this->display();
        //修改密码
        $data['email'] = I("post.email");
        $data['password'] = I("post.old_password");
        $user =  $this->user->where($data)->find();
        if(!$user){
            $this->error("您输入的旧密码错误");
        }
        $data['password'] = I('post.password');
        $user->where($data)->save();
//        $this->success('修改密码成功');
        //跳转
        $this->success('密码修改成功，请重新登陆',$this->user->logout());
    }

}